package com.kaiyidiannao.https;

import android.content.Context;
import android.util.Log;
import com.kaiyidiannao.data.DataCenter;
import com.kaiyidiannao.model.Result;

import java.util.Map;

public class HttpUtils {
    // 网络连接部分
    public static Result postByHttpClient(String url, Map<String, String> params) {
        return CustomHttpClient.PostFromWebByHttpClient(url, params);
    }

    public static Result getByHttpClient(String url, Map<String, String> params) {
        return CustomHttpClient.getFromWebByHttpClient(url, params);
    }
    // ------------------------------------------------------------------------------------------
    // 网络连接判断
    // 判断是否有网络
	public static boolean isNetworkAvailable() {
		return NetWorkHelper.isNetworkAvailable(DataCenter.context);
	}

    //判断网络是否连接（yes）
    public static boolean isConnected() {
        return NetWorkHelper.isConnected(DataCenter.context);
    }

    // 判断mobile网络是否可用
    public static boolean isMobileDataEnable(Context context) {
        String TAG = "httpUtils.isMobileDataEnable()";
        try {
            return NetWorkHelper.isMobileDataEnable(context);
        } catch (Exception e) {
            Log.e(TAG, e.getMessage());
            e.printStackTrace();
            return false;
        }
    }

    // 判断wifi网络是否可用
    public static boolean isWifiDataEnable(Context context) {
        String TAG = "httpUtils.isWifiDataEnable()";
        try {
            return NetWorkHelper.isWifiDataEnable(context);
        } catch (Exception e) {
            Log.e(TAG, e.getMessage());
            e.printStackTrace();
            return false;
        }
    }

    // 判断是否为漫游
    public static boolean isNetworkRoaming(Context context) {
        return NetWorkHelper.isNetworkRoaming(context);
    }
}
